import time
from queue import Queue

from selenium import webdriver

option = webdriver.ChromeOptions()
option.add_argument(
    'User-Agent=Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.81 Safari/537.36')
client = webdriver.Chrome(executable_path='chromedriver.exe', options=option)
client.get('https://kyfw.12306.cn/otn/view/index.html')

def get_cookies():
    while True:
        if client.current_url == 'https://kyfw.12306.cn/otn/view/index.html' or  client.current_url=='https://www.12306.cn/mormhweb/logFiles/error.html':
            cookies = ''
            for cookie in client.get_cookies():
                cookies += cookie['name'] + '=' + cookie['value'] + ';'
            cookies = cookies[:-1]
            return cookies
